<template>
    <div class="newsinfo-container">
        <h3 class="title">{{ newsinfo.title }}</h3>
        <p class="subtitle">
            <span>发表时间：{{ newsinfo.time | dateFormat }}</span>
            <span>点击：{{ newsinfo.click }}次</span>
        </p>
        <hr>
        <!-- 内容区域 -->
        <div class="content" v-html="newsinfo.content">

        </div>

        <!-- 评论区域--子组件 -->
        <comment-box :id="this.id"></comment-box>
    </div>
</template>

<script>
import comment from '../subcomponent/comment.vue'
import { Toast } from 'mint-ui'

export default {
    data(){
        return {
            id: this.$route.params.id,
            newsinfo: {}
        }
    },
    methods:{
        getNewsInfo(){
            this.$http.get('json/newsinfo/' + this.id ).then(reslut => {
                if(reslut.status === 200 ){
                    this.newsinfo = reslut.body
                    this.newsinfo.time = Date.now()
                }else{
                    Toast('加载失败')
                }
            })
        }
    },
    created(){
        this.getNewsInfo()
    },
    components:{
        "comment-box":comment
    }
}
</script>
<style lang="less" scoped>
    .newsinfo-container{
        padding: 0 4px;
        .title{
            font-size: 16px;
            margin: 15px 0;
            text-align: center;
        }
        .subtitle{
            display: flex;
            justify-content: space-between;
        }
        .content{
            font-size: 14px;
            color: #666;
        }
    }
</style>


